<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The Parle\Parser class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parle-rlexer.reset.html">« Parle\RLexer::reset</a></li>
      <li style="float: right;"><a href="parle-parser.advance.html">Parle\Parser::advance »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.parle.html">Parle</a></li>
    <li>The Parle\Parser class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.parle-parser" class="reference">

 <h1 class="title">The Parle\Parser class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL parle &gt;= 0.5.1)</p>


  <div class="section" id="parle-parser.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    Parser class. Rules can be defined on the fly. Once finalized, a <span class="classname"><a href="class.parle-lexer.html" class="classname">Parle\Lexer</a></span> instance is required to deliver the token stream.
   </p>
  </div>


  <div class="section" id="parle-parser.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">Parle\Parser</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.action-error"><var class="varname">ACTION_ERROR</var></a></var><span class="initializer"> = 0</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.action-shift"><var class="varname">ACTION_SHIFT</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.action-reduce"><var class="varname">ACTION_REDUCE</var></a></var><span class="initializer"> = 2</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.action-goto"><var class="varname">ACTION_GOTO</var></a></var><span class="initializer"> = 3</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.action-accept"><var class="varname">ACTION_ACCEPT</var></a></var><span class="initializer"> = 4</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.error-syntax"><var class="varname">ERROR_SYNTAX</var></a></var><span class="initializer"> = 0</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.error-non-associative"><var class="varname">ERROR_NON_ASSOCIATIVE</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.parle-parser.html#parle-parser.constants.error-unknown-token"><var class="varname">ERROR_UNKNOWN_TOKEN</var></a></var><span class="initializer"> = 2</span>;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.parle-parser.html#parle-parser.props.action">$<var class="varname">action</var></a></var><span class="initializer"> = 0</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.parle-parser.html#parle-parser.props.reduceId">$<var class="varname">reduceId</var></a></var><span class="initializer"> = 0</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="parle-parser.advance.html" class="methodname">advance</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.build.html" class="methodname">build</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.consume.html" class="methodname">consume</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><a href="class.parle-lexer.html" class="type Parle\Lexer">Parle\Lexer</a></span> <code class="parameter">$lexer</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.dump.html" class="methodname">dump</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.errorinfo.html" class="methodname">errorInfo</a></span>(): <span class="type"><a href="class.parle-errorinfo.html" class="type Parle\ErrorInfo">Parle\ErrorInfo</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.left.html" class="methodname">left</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.nonassoc.html" class="methodname">nonassoc</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.precedence.html" class="methodname">precedence</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.push.html" class="methodname">push</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$rule</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.reset.html" class="methodname">reset</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$tokenId</code><span class="initializer"> = ?</span></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.right.html" class="methodname">right</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.sigil.html" class="methodname">sigil</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$idx</code></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.token.html" class="methodname">token</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.tokenid.html" class="methodname">tokenId</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$tok</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.trace.html" class="methodname">trace</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="parle-parser.validate.html" class="methodname">validate</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><a href="class.parle-lexer.html" class="type Parle\Lexer">Parle\Lexer</a></span> <code class="parameter">$lexer</code></span>): <span class="type">bool</span></div>

   }</div>


  </div>
  

  <div class="section" id="parle-parser.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="parle-parser.constants.action-error"><strong><code>Parle\Parser::ACTION_ERROR</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.action-shift"><strong><code>Parle\Parser::ACTION_SHIFT</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.action-reduce"><strong><code>Parle\Parser::ACTION_REDUCE</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.action-goto"><strong><code>Parle\Parser::ACTION_GOTO</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.action-accept"><strong><code>Parle\Parser::ACTION_ACCEPT</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.error-syntax"><strong><code>Parle\Parser::ERROR_SYNTAX</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.error-non-associative"><strong><code>Parle\Parser::ERROR_NON_ASSOCIATIVE</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="parle-parser.constants.error-unknown-token"><strong><code>Parle\Parser::ERROR_UNKNOWN_TOKEN</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

   </dl>

  </div>



  <div class="section" id="parle-parser.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="parle-parser.props.action"><var class="varname">action</var></dt>

     <dd>

      <p class="para">Current parser action that matches one of the action class constants, readonly.</p>
     </dd>

    
    
     <dt id="parle-parser.props.reduceId"><var class="varname">reduceId</var></dt>

     <dd>

      <p class="para">Grammar rule id just processed in the reduce action. The value corresponds either to a token or to a production id. Readonly.</p>
     </dd>

    
   </dl>

  </div>


 </div>

 
 

















































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="parle-parser.advance.html">Parle\Parser::advance</a> — Process next parser rule</li><li><a href="parle-parser.build.html">Parle\Parser::build</a> — Finalize the grammar rules</li><li><a href="parle-parser.consume.html">Parle\Parser::consume</a> — Consume the data for processing</li><li><a href="parle-parser.dump.html">Parle\Parser::dump</a> — Dump the grammar</li><li><a href="parle-parser.errorinfo.html">Parle\Parser::errorInfo</a> — Retrieve the error information</li><li><a href="parle-parser.left.html">Parle\Parser::left</a> — Declare a token with left-associativity</li><li><a href="parle-parser.nonassoc.html">Parle\Parser::nonassoc</a> — Declare a token with no associativity</li><li><a href="parle-parser.precedence.html">Parle\Parser::precedence</a> — Declare a precedence rule</li><li><a href="parle-parser.push.html">Parle\Parser::push</a> — Add a grammar rule</li><li><a href="parle-parser.reset.html">Parle\Parser::reset</a> — Reset parser state</li><li><a href="parle-parser.right.html">Parle\Parser::right</a> — Declare a token with right-associativity</li><li><a href="parle-parser.sigil.html">Parle\Parser::sigil</a> — Retrieve a matching part of a rule</li><li><a href="parle-parser.token.html">Parle\Parser::token</a> — Declare a token</li><li><a href="parle-parser.tokenid.html">Parle\Parser::tokenId</a> — Get token id</li><li><a href="parle-parser.trace.html">Parle\Parser::trace</a> — Trace the parser operation</li><li><a href="parle-parser.validate.html">Parle\Parser::validate</a> — Validate input</li></ul>
</div>
</div></div></body></html>